<html>
<head><meta charset="utf-8"><title>range/slice patterns · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html">range/slice patterns</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="239487207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239487207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239487207">(May 19 2021 at 20:01)</a>:</h4>
<p>I think there's some miscommunication regarding my comments in the "Stabilizing RangeFrom" PR in <a href="https://github.com/rust-lang/rust/pull/83918">https://github.com/rust-lang/rust/pull/83918</a> and I figured I'd open a thread here to help clarify.</p>



<a name="239487227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239487227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239487227">(May 19 2021 at 20:01)</a>:</h4>
<p>From the meeting minutes it seems as though the lang team has the impression that I was proposing that <code>match [1] { [0..] =&gt;</code> should be an error merely to prevent confusion with slice patterns, for which they recommend that it should just be a lint instead. However, what I was proposing was that this construction should be an error because it I believe it ought to actually have the semantics of slice patterns, which will be much more difficult (requiring an edition change at the minimum) if the current semantics are stabilized.</p>



<a name="239487915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239487915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239487915">(May 19 2021 at 20:05)</a>:</h4>
<p>In particular I am proposing that the following should be made to work:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">match</span><span class="w"> </span><span class="p">[</span><span class="mi">9</span><span class="p">,</span><span class="mi">8</span><span class="p">,</span><span class="mi">7</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="n">head</span><span class="w"> </span><span class="o">@</span><span class="w"> </span><span class="mi">0</span><span class="o">..</span><span class="p">,</span><span class="w"> </span><span class="n">tail</span><span class="p">]</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="fm">assert_eq!</span><span class="p">([</span><span class="mi">9</span><span class="p">,</span><span class="w"> </span><span class="mi">8</span><span class="p">],</span><span class="w"> </span><span class="n">head</span><span class="p">),</span><span class="w"></span>
</code></pre></div>
<p>...which will be a backwards-incompatible change if <code>0..</code> in slice pattern position is taken to mean a range pattern rather than a slice pattern</p>



<a name="239488028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239488028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239488028">(May 19 2021 at 20:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> does that clear things up?</p>



<a name="239488100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239488100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239488100">(May 19 2021 at 20:07)</a>:</h4>
<p><span class="user-mention" data-user-id="256342">@bstrie</span>  I think if we did that, that would not be compatible with our current handling of range patterns outside of slices.</p>



<a name="239488120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239488120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239488120">(May 19 2021 at 20:07)</a>:</h4>
<p>note that by "should be made to work" and I am not implying that this PR should do it</p>



<a name="239488161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239488161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239488161">(May 19 2021 at 20:07)</a>:</h4>
<p>That said, I also wouldn't object to prohibiting range patterns entirely inside slice patterns.</p>



<a name="239488272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239488272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239488272">(May 19 2021 at 20:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/range.2Fslice.20patterns/near/239488100">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span>  I think if we did that, that would not be compatible with our current handling of range patterns outside of slices.</p>
</blockquote>
<p>I'm not sure what you mean by this, here's code that works today:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="o">-</span><span class="mi">100</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mi">50</span><span class="p">,</span><span class="w"> </span><span class="mi">50</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p">];</span><span class="w"></span>

<span class="fm">assert_eq!</span><span class="p">(</span><span class="o">&amp;</span><span class="n">x</span><span class="p">[</span><span class="o">..</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="o">-</span><span class="mi">100</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mi">50</span><span class="p">,</span><span class="w"> </span><span class="mi">50</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p">]);</span><span class="w"></span>
<span class="fm">assert_eq!</span><span class="p">(</span><span class="o">&amp;</span><span class="n">x</span><span class="p">[</span><span class="o">..</span><span class="mi">2</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="o">-</span><span class="mi">100</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mi">50</span><span class="p">]);</span><span class="w"></span>
<span class="fm">assert_eq!</span><span class="p">(</span><span class="o">&amp;</span><span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="o">..</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="mi">50</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p">]);</span><span class="w"></span>
<span class="fm">assert_eq!</span><span class="p">(</span><span class="o">&amp;</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="o">..</span><span class="mi">3</span><span class="p">],</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="o">-</span><span class="mi">50</span><span class="p">,</span><span class="w"> </span><span class="mi">50</span><span class="p">]);</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="n">y</span><span class="w"> </span><span class="o">@</span><span class="w"> </span><span class="o">..</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="fm">assert_eq!</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="p">);</span><span class="w"></span>
</code></pre></div>
<p>it seems natural to extend this behavior to pattern position as well</p>



<a name="239488501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239488501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239488501">(May 19 2021 at 20:10)</a>:</h4>
<p>IMO, it is more important that "<code>..</code> syntax inside of slices" should be consistent with itself, rather than "<code>..</code> syntax outside of slices should be consistent with <code>..</code> syntax inside of slices". we already have both, so we're forced to choose either way</p>



<a name="239488646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239488646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239488646">(May 19 2021 at 20:11)</a>:</h4>
<p>(there is of course the problematic case of <code>[x..=y]</code> which is already stable, but I believe that was a simple oversight and that the effect on slice patterns was never raised)</p>



<a name="239488682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239488682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239488682">(May 19 2021 at 20:11)</a>:</h4>
<p>I'd be willing to write an RFC to propose this if people would like, I'd just like to gauge interest from the lang team first</p>



<a name="239489977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239489977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239489977">(May 19 2021 at 20:22)</a>:</h4>
<p>Pondering interactions: I wonder if we ever get splatting in the future, if that would extend to more-general "splatting patterns" that would remove the <code>..</code> ambiguity.</p>



<a name="239906668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239906668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239906668">(May 22 2021 at 23:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/range.2Fslice.20patterns/near/239489977">said</a>:</p>
<blockquote>
<p>Pondering interactions: I wonder if we ever get splatting in the future, if that would extend to more-general "splatting patterns" that would remove the <code>..</code> ambiguity.</p>
</blockquote>
<p>Possibly, though (as I envision it) it would be more restrictive than what I'm proposing here. During the original slice patterns RFC I proposed <code>..foo..</code> as a syntax for slice patterns that would desugar to <code>foo @ ..</code> and could then be used in expression context akin to python's <code>*foo</code>. That gives you nice syntax for things that already compile today with slice patterns, e.g. <code>[..head.., tail]</code>, <code>[head, ..tail..]</code>, <code>[head, ..middle.., tail]</code>. But I don't think there's an intuitive/nice syntax for e.g. splitting a <code>[T; 4]</code> in half with <code>[first @ ..2, last @ 2..]</code>, or getting only the middle of a slice with <code>[middle @ 1..3]</code>, etc; anything that requires 1) more than one splat, or 2) specifying indexes won't really be possible if the syntactic space is used to mean a range pattern rather than a slice pattern.</p>



<a name="239907263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239907263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239907263">(May 22 2021 at 23:13)</a>:</h4>
<p>Hmm, that examples makes me wish that <code>[first @ ..k, last @ k..]</code> could work as a general way to <code>split_at_mut</code>, but of course runtime values can't get into patterns like that, so it'd be pretty sketchy at best.</p>



<a name="239907343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239907343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239907343">(May 22 2021 at 23:15)</a>:</h4>
<p>I guess I was thinking, with splatting, of something like <code>[...first:[_; 2], rest @ ..]</code> as the potential alternative to <code>2..</code>.</p>



<a name="239908243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/239908243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#239908243">(May 22 2021 at 23:33)</a>:</h4>
<p>you could be <em>extremely</em> hacky and say that the presence of a binding is what creates a slice pattern, e.g. <code>[1..2]</code> is a range pattern and <code>[a @ 1..2]</code> is a slice pattern. You could also use <code>[]</code> to force a slice pattern as in <code>[middle @ [1..3]]</code> (but of course we're back to the same syntactic problem...). In any case, ultimately I don't think that the desire to use a range pattern inside of an array is anywhere as common as the desire to use a more sophisticated slice pattern, but I only have my own desires to base this on.</p>



<a name="240080365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/240080365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#240080365">(May 24 2021 at 17:05)</a>:</h4>
<p>I am not convinced of that last point</p>



<a name="240080493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/240080493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#240080493">(May 24 2021 at 17:06)</a>:</h4>
<p>I'd like to see some examples of where patterns like these are useful in practice</p>



<a name="240080557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/240080557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#240080557">(May 24 2021 at 17:07)</a>:</h4>
<p>To be honest, both "range patterns in slices" and "extended slice patterns" seem like increasingly narrow use cases to me</p>



<a name="240080580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/240080580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#240080580">(May 24 2021 at 17:07)</a>:</h4>
<p>I'm somewhat inclined to learn towards consistency of patterns overall for that reason</p>



<a name="240082876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/240082876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#240082876">(May 24 2021 at 17:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/range.2Fslice.20patterns/near/240080580">said</a>:</p>
<blockquote>
<p>I'm somewhat inclined to learn towards consistency of patterns overall for that reason</p>
</blockquote>
<p>Consistency is the root of my argument here; In pattern contexts I would like <code>[..]</code> to be consistent with <code>[0..]</code>, as it meshes with my mental model of <code>..</code> as just "a range with the endpoints filled in automatically". It's likewise consistent with <code>foo[0..]</code> in expression contexts.</p>



<a name="241573828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/241573828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#241573828">(Jun 04 2021 at 18:13)</a>:</h4>
<p>imo, I agree with bstrie that there is an inherent desirability in making SliceIndexing and slice patterns "line up". I often want to destructure slices in ways akin to this, and I have seen others have similar desires... it's especially a bear to have to, e.g.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">d</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="n">g</span><span class="p">,</span><span class="w"> </span><span class="n">h</span><span class="p">,</span><span class="w"> </span><span class="n">rest</span><span class="w"> </span><span class="o">@</span><span class="w"> </span><span class="o">..</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">byteslice</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">num</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kt">u64</span>::<span class="n">from_le_bytes</span><span class="p">([</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">d</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="n">g</span><span class="p">,</span><span class="w"> </span><span class="n">h</span><span class="p">]);</span><span class="w"></span>
</code></pre></div>
<p>when it could be</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="p">[</span><span class="n">octobyte</span><span class="w"> </span><span class="mi">0</span><span class="o">..</span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">rest</span><span class="w"> </span><span class="o">@</span><span class="w"> </span><span class="o">..</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">byteslice</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">num</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kt">u64</span>::<span class="n">from_le_bytes</span><span class="p">(</span><span class="n">octobyte</span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="243576287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243576287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243576287">(Jun 22 2021 at 20:43)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="239881">@Josh Triplett</span> Hi! I'm okay with continuing from here.</p>
<p>Also I keep seeing remarks like "I wish SliceIndex let me produce an array when slicing known values" and similar things. ^^;</p>



<a name="243599179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243599179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243599179">(Jun 23 2021 at 01:47)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> Would you mind elaborating a bit more on how you might imagine making this forwards-compatible in the direction of what bstrie suggested?</p>



<a name="243681735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243681735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243681735">(Jun 23 2021 at 17:02)</a>:</h4>
<p>bstrie's idea re: compatibility migration seemed fine? I legit do not understand why this is blocked at this point.</p>



<a name="243682043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682043">(Jun 23 2021 at 17:05)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> Judging by the conversation in the last lang meeting, I think the issue is that we're a bit lost as to what change is being proposed. :)</p>



<a name="243682069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682069">(Jun 23 2021 at 17:05)</a>:</h4>
<p>There's been quite a lot of discussion.</p>



<a name="243682123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682123">(Jun 23 2021 at 17:05)</a>:</h4>
<p>Could we get a pointer to a specific proposal for how this could be changed for compatibility?</p>



<a name="243682386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682386">(Jun 23 2021 at 17:07)</a>:</h4>
<p>There has been only <strong>one</strong> material change to the PR:<br>
Range patterns within slice patterns <strong>remain unstable</strong> behind the feature gate.<br>
The goal being that bstrie has a plan for that, and it being unstable would allow future action on it.</p>



<a name="243682460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682460">(Jun 23 2021 at 17:07)</a>:</h4>
<p>Ah, I see. I think that may have gotten a bit buried under some of the discussions for what that future action might be. :)</p>



<a name="243682536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682536">(Jun 23 2021 at 17:08)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> for making such nesting remain unstable and evaluating future possibilities there.</p>



<a name="243682539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682539">(Jun 23 2021 at 17:08)</a>:</h4>
<p>Nothing else is of concern to T-lang's decision here, and I made only the most minimal change <strong>precisely</strong> to remove having to make a decision as to the final shape of future plans for that.</p>



<a name="243682796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682796">(Jun 23 2021 at 17:10)</a>:</h4>
<p>I think that's exactly the nature of the confusion that we had when this came up in the lang meeting yesterday. I appreciate you clarifying that!</p>



<a name="243682832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682832">(Jun 23 2021 at 17:10)</a>:</h4>
<p>/me re-reads the PR history...</p>



<a name="243682914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243682914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243682914">(Jun 23 2021 at 17:11)</a>:</h4>
<p>Ah, I see; <a href="https://github.com/rust-lang/rust/pull/83918/commits/43bad44ff01dd5035b961b366e65f705241b428d">https://github.com/rust-lang/rust/pull/83918/commits/43bad44ff01dd5035b961b366e65f705241b428d</a> was the commit that re-gated range patterns within slice patterns.</p>



<a name="243683241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243683241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243683241">(Jun 23 2021 at 17:13)</a>:</h4>
<p>Yes.<br>
My understanding was that Niko included an objection (in <a href="https://github.com/rust-lang/rust/pull/83918#issuecomment-855162216">https://github.com/rust-lang/rust/pull/83918#issuecomment-855162216</a>) against the range pattern in certain cases being "held back" as unstable. But I genuinely had not given these special cases of patterns deep thought, which is why I was amenable to this.</p>



<a name="243683421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243683421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243683421">(Jun 23 2021 at 17:15)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/83918#issuecomment-867016780">https://github.com/rust-lang/rust/pull/83918#issuecomment-867016780</a></p>



<a name="243683510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243683510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243683510">(Jun 23 2021 at 17:15)</a>:</h4>
<p>I'm a big fan of doing this incrementally. Thanks for taking the time to clarify exactly how this PR interacted with that future possibility.</p>



<a name="243683742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/range/slice%20patterns/near/243683742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/range.2Fslice.20patterns.html#243683742">(Jun 23 2021 at 17:17)</a>:</h4>
<p>huzzah! And thank you for taking the time to review. ^^;</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>